indexModule.controller('noticeSave',function($scope,$http,$routeParams){
    //网站id
    $scope.id = $routeParams.id;

    //修改留言时，获取留言详情
    if($scope.id){
        var postData = {id:$scope.id};
        postHttp($http,config.noticeDetail_httpUrl,postData,function(data){
            $scope.title = data.data.title;
            $scope.content = data.data.content;
        });
    };

    //保存留言
    $scope.saveArticle = function(){
        var title = $scope.title;
        var content = $scope.content;
        if(title && content){
            if($scope.id){
                var postData = {id:$scope.id,title:title,content:content};
            }else{
                var postData = {title:title,content:content};
            }
            postHttp($http,config.noticeSave_httpUrl,postData,function(data){
                alert(config.saveHttpMsg);
                window.location.reload();
            });
        }else{
            return alert(config.talkMissVal);
        }
    };
});

